﻿<Window x:Class="SenenFernandez.WindowResizer.MainView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:s="clr-namespace:System;assembly=mscorlib"
        xmlns:p="clr-namespace:SenenFernandez.WindowResizer.Properties"
        xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:Interactions="clr-namespace:SenenFernandez.SmartExtensionMethods.Interactivity;assembly=SenenFernandez.SmartExtensionMethods"
        xmlns:ViewModel="clr-namespace:SenenFernandez.WindowResizer"
        WindowStartupLocation="CenterScreen"
        FocusManager.FocusedElement="{Binding ElementName=ResizeLeft}"
        Name="MainWindow">
    <Window.Style>
        <Style TargetType="Window">
            <Setter Property="Title" Value="{x:Static p:Resources.ApplicationTitle}" />
            <Setter Property="SizeToContent" Value="WidthAndHeight" />
            <Setter Property="ShowInTaskbar" Value="False" />
            <Setter Property="Topmost" Value="True" />
            <Setter Property="WindowStyle" Value="None" />
            <Setter Property="AllowsTransparency" Value="True" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="MinWidth" Value="400" />
            <Setter Property="MaxWidth" Value="800" />
            <Setter Property="MinHeight" Value="200" />
            <Setter Property="MaxHeight" Value="400" />
            <Setter Property="FontFamily" Value="Segoe UI" />
            <Setter Property="FontWeight" Value="Bold" />
            <Setter Property="FontSize" Value="14" />
            <Style.Triggers>
                <Trigger Property="AllowsTransparency" Value="False">
                    <Setter Property="Background" Value="#FFFFFFFF" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Style>
    <Window.Resources>
        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#AA41D030" />
        <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="#AA41D030" />
        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="#FF000000" />
        <Style TargetType="TextBox">
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="SelectionBrush" Value="#AA41D030" />
        </Style>
        <Style x:Key="DefaultButton" TargetType="Button">
            <Setter Property="Cursor" Value="Hand" />
            <Setter Property="Background" Value="#AA41D030" />
            <Setter Property="Margin" Value="1" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Border x:Name="Border"
                                BorderThickness="1" CornerRadius="5"
                                Background="{TemplateBinding Background}"
                                BorderBrush="#EE159805">
                            <ContentPresenter Margin="2"
                                              HorizontalAlignment="Center"
                                              VerticalAlignment="Center"
                                              RecognizesAccessKey="True"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" Value="#FF41D030" />
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="RenderTransform">
                                    <Setter.Value>
                                        <ScaleTransform ScaleX="0.995" ScaleY="0.995" />
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style TargetType="ComboBox">
            <Setter Property="Cursor" Value="Hand" />
            <Setter Property="Background" Value="#AA41D030" />
            <Setter Property="BorderBrush" Value="#EE159805" />
        </Style>
        <Style TargetType="ListBox">
            <Setter Property="Cursor" Value="Hand" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="BorderBrush" Value="#EE159805" />
        </Style>
        <Style x:Key="HeaderBorder" TargetType="Border">
            <Setter Property="Cursor" Value="Hand" />
            <Setter Property="DockPanel.Dock" Value="Top" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="VerticalAlignment" Value="Stretch" />
            <Setter Property="Margin" Value="2" />
            <Setter Property="Padding" Value="2" />
            <Setter Property="Background" Value="#6600AFFF" />
            <Setter Property="BorderThickness" Value="2" />
            <Setter Property="BorderBrush" Value="#CC00AFFF" />
            <Setter Property="CornerRadius" Value="5" />
        </Style>
        <Style x:Key="WindowTitle" TargetType="Label">
            <Setter Property="Foreground" Value="White" />
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="Content" Value="{x:Static p:Resources.ApplicationTitle}" />
            <Setter Property="Effect">
                <Setter.Value>
                    <DropShadowEffect ShadowDepth="4" Direction="315" Color="#CC658FA2" Opacity="0.7" BlurRadius="4" />
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="CloseButton" TargetType="Button" BasedOn="{StaticResource DefaultButton}">
            <Setter Property="DockPanel.Dock" Value="Right" />
            <Setter Property="Content" Value="X" />
            <Setter Property="Width" Value="32" />
            <Setter Property="HorizontalAlignment" Value="Right" />
            <Setter Property="IsCancel" Value="True" />
        </Style>
        <Style x:Key="ContentBorder" TargetType="Border">
            <Setter Property="Padding" Value="5" />
            <Setter Property="Background" Value="#99FFFFFF" />
            <Setter Property="BorderThickness" Value="2" />
            <Setter Property="BorderBrush" Value="#EE159805" />
            <Setter Property="CornerRadius" Value="5" />
        </Style>
        <Style x:Key="OptionsPanel" TargetType="DockPanel">
            <Setter Property="Margin" Value="5" />
            <Setter Property="DockPanel.Dock" Value="Right" />
        </Style>
        <Style x:Key="LinkText" TargetType="TextBlock">
            <Setter Property="DockPanel.Dock" Value="Bottom" />
            <Setter Property="HorizontalAlignment" Value="Right" />
            <Setter Property="ToolTip" Value="{x:Static p:Resources.WebsiteToolTip}" />
        </Style>
        <Style TargetType="Button" BasedOn="{StaticResource DefaultButton}" />
        <Style TargetType="ToolTip">
            <Setter Property="FontSize" Value="14" />
            <Setter Property="FontWeight" Value="Bold" />
            <Setter Property="Foreground" Value="#FFFFFFFF" />
            <Setter Property="Background" Value="#AA41D030" />
            <Setter Property="BorderBrush" Value="#EE159805" />
            <Setter Property="BorderThickness" Value="2" />
            <Setter Property="HasDropShadow" Value="True" />
            <Setter Property="Padding" Value="5" />
            <Style.Triggers>
                <EventTrigger RoutedEvent="ToolTip.Loaded">
                    <BeginStoryboard>
                        <Storyboard TargetProperty="Opacity">
                            <DoubleAnimation From="1" To="0.75" Duration="0:0:10" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Style.Triggers>
        </Style>
        <Style TargetType="Label">
            <Setter Property="ToolTipService.ShowDuration" Value="{x:Static s:Int32.MaxValue}" />
            <Setter Property="ToolTipService.InitialShowDelay" Value="0" />
            <Setter Property="ToolTipService.BetweenShowDelay" Value="0" />
        </Style>
    </Window.Resources>
    <Window.DataContext>
        <ViewModel:MainViewModel />
    </Window.DataContext>
    <Interactivity:Interaction.Triggers>
        <Interactivity:EventTrigger EventName="MouseLeftButtonDown">
            <Interactivity:InvokeCommandAction Command="{Binding DragMove}" CommandParameter="{Binding ElementName=MainWindow}" />
        </Interactivity:EventTrigger>
        <Interactivity:EventTrigger EventName="Loaded">
            <Interactivity:InvokeCommandAction Command="{Binding Loaded}" />
        </Interactivity:EventTrigger>
        <Interactivity:EventTrigger EventName="Activated">
            <Interactivity:InvokeCommandAction Command="{Binding Activated}" />
        </Interactivity:EventTrigger>
    </Interactivity:Interaction.Triggers>
    <DockPanel>
        <Border Style="{StaticResource HeaderBorder}">
            <DockPanel>
                <Button Style="{StaticResource CloseButton}" Command="{Binding Closed}"
                        CommandParameter="{Binding ElementName=MainWindow}" />
                <Label Style="{StaticResource WindowTitle}" />
            </DockPanel>
        </Border>
        <TextBlock Style="{StaticResource LinkText}">
            <Hyperlink>
                <Run Name="Link" Text="{x:Static p:Resources.Website}">
                    <Run.InputBindings>
                        <MouseBinding Gesture="LeftClick" Command="{Binding Navigate}"
                                      CommandParameter="{Binding ElementName=Link, Path=Text}" />
                    </Run.InputBindings>
                </Run>
            </Hyperlink>
        </TextBlock>
        <Border Style="{StaticResource ContentBorder}">
            <DockPanel>
                <DockPanel Style="{StaticResource OptionsPanel}">
                    <UniformGrid Columns="2" DockPanel.Dock="Top">
                        <Label Content="{x:Static p:Resources.Monitor}" />
                        <ComboBox ItemsSource="{Binding Monitors}" DisplayMemberPath="Name" SelectedItem="{Binding SelectedMonitor}" />
                        <Label Content="{x:Static p:Resources.ResizeLeft}" />
                        <TextBox Name="ResizeLeft" Text="{Binding Path=ResizeLeft, UpdateSourceTrigger=PropertyChanged}" />
                        <Label Content="{x:Static p:Resources.ResizeTop}" />
                        <TextBox Text="{Binding ResizeTop, UpdateSourceTrigger=PropertyChanged}" />
                        <Label Content="{x:Static p:Resources.ResizeWidth}" />
                        <TextBox Text="{Binding ResizeWidth, UpdateSourceTrigger=PropertyChanged}" />
                        <Label Content="{x:Static p:Resources.ResizeHeight}" />
                        <TextBox Text="{Binding ResizeHeight, UpdateSourceTrigger=PropertyChanged}" />
                    </UniformGrid>
                    <Button Content="{x:Static p:Resources.Resize}" Command="{Binding Resize}" IsDefault="True" />
                </DockPanel>
                <ListBox ItemsSource="{Binding Windows}" SelectedItem="{Binding SelectedWindow}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Label Content="{Binding Name}" ToolTip="{Binding Name}" />
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </DockPanel>
        </Border>
    </DockPanel>
</Window>